//
//  NSDate+BCustom.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/12/5.
//  Copyright © 2018 guoshikeji. All rights reserved.
//

#import "NSDate+BCustom.h"

@implementation NSDate (BCustom)

+ (long)secondsBetweenDate:(NSDate *)date endDate:(NSDate *)endDate {
    if (date&&endDate) {
        long seconds = (long)(endDate.conversionTimestamp-date.conversionTimestamp);
        return MAX(0, seconds);
    }
    return 0;
}

//HH:mm:ss
+ (NSString *)countdownStringBetweenDate:(NSDate *)date endDate:(NSDate *)endDate {
    long seconds = [self secondsBetweenDate:date endDate:endDate];
    long hours = seconds/D_HOUR;
    long lastSeconds = seconds%D_HOUR;
    long minites = lastSeconds/D_MINUTE;
    long second = lastSeconds%D_MINUTE;
    //
    return [NSString stringWithFormat:@"%.2ld:%.2ld:%.2ld",hours,minites,second];
}

@end
